define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    if(Config.transfer_id == '' || Config.transfer_id == null){
        Config.transfer_id = 0;
    }
    if(Config.type == '' || Config.type == null){
        Config.type = 0;
    }
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feditionordertransfer/index/?transfer_id=' + Config.transfer_id + '&type=' + Config.type,
                    add_url: 'feditionordertransfer/add',
                    edit_url: 'feditionordertransfer/edit',
                    del_url: '',
                    multi_url: 'feditionordertransfer/multi',
                    import_url: 'feditionordertransfer/import/?transfer_id=' + Config.transfer_id,
                    table: 'fedition_ordertransfer',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                searchFormVisible: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'transfer_number', title: __('Transfer_number'), operate: 'LIKE'},
                        {field: 'freight', title: __('Freight'), operate:'BETWEEN'},
                        {field: 'fedition_name', title: __('店铺'), operate:'LIKE'},
                        {field: 'status', title: __('Status'), searchList: {"normal":__('匹配成功'),"hidden":__('待匹配')}, formatter: Table.api.formatter.status},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});